﻿/// <summary>
/// https://leetcode-cn.com/problems/set-matrix-zeroes/
/// </summary>
public class Solution
{
    public void SetZeroes(int[][] matrix)
    {
        List<int> zeroRows = new List<int>();
        List<int> zeroCols = new List<int>();
        for (int i = 0; i < matrix.Length; i++)
        {
            for (int j = 0; j < matrix[i].Length; j++)
            {
                if (matrix[i][j] is 0)
                {
                    zeroRows.Add(i);
                    zeroCols.Add(j);
                }
            }
        }

        foreach (var r in zeroRows)
        {
            for (int j = 0; j < matrix[r].Length; j++)
            {
                matrix[r][j] = 0;
            }
        }

        foreach (var c in zeroCols)
        {
            for (int i = 0; i < matrix.Length; i++)
            {
                matrix[i][c] = 0;
            }
        }
    }
}